<?php


class folder_toolsComponents extends sfComponents {
	
  	public function executeShow_folders() {
	
	
  	  if(isset($tools))
  	  {
  	  	$this->tools = true;
  	  }
  	  else 
  	  {
  	  	$this->tools = false;
  	  }
        
        ////Выбираем  корневой каталог 
         $c = new Criteria();    
        //$c->add(FolderPeer::USER_ID, $this->getUser()->getAttribute( 'user_id', null, 'sfGuardSecurityUser' ));
        $c->add(FolderPeer::TREE_LEFT,1);
        $this->folders= FolderPeer::doSelect($c);

        ///Формируем и передаем массив запомненных каталогов      
        $cr = new Criteria();
        $cr -> add(RememberPeer::USER_ID,$this->getUser()->getAttribute( 'user_id', null, 'sfGuardSecurityUser' ));
        $cr->addAnd(RememberPeer::CLASS_NAME,'Folder');    
        $rem = RememberPeer::doSelect($cr);
        $ra = array();
        foreach ($rem as $r)
        {
        	$ra[$r->getId()] = $r->getItemId();
        }
        $this->rem = $ra;
	}
	
	
	public function executeShow_jqfolders() {
	
	  if($this->tools)
  	  {
  	  	$this->tools = true;
  	  }
  	  else 
  	  {
  	  	$this->tools = false;
  	  }
         ////Выбираем  корневой каталог 
         $c = new Criteria();    
       
        $c->add(FolderPeer::TREE_LEFT,1);
        $this->folders= FolderPeer::doSelect($c);

       
	}
	
	
	public function executeOpen_folder() {
		
		$this->cur_f = FolderPeer::retrieveByPK ( $this->id );
		$this->folders = $this->cur_f->getChildren ();

		
	}

}
?>